package carouselMap

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"
	"gitee.com/liuxuezhan/ar-platform/admin-api/pkg/code"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/setting/client/carouselmap"
	"github.com/zeromicro/go-zero/core/logc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelCarouselMapLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 删除
func NewDelCarouselMapLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelCarouselMapLogic {
	return &DelCarouselMapLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelCarouselMapLogic) DelCarouselMap(req *types.DelCarouselMapReq) (resp *types.Empty, err error) {
	if req.Id == 0 {
		return nil, code.ParamsInvalid
	}

	u, err := l.svcCtx.SettingService.CarouselMap.DelCarouselMap(l.ctx, &carouselmap.DelCarouselMapReq{Id: req.Id, MerchantId: 1})

	if err != nil {
		logc.Error(l.ctx, "DelCarouselMap err:", err)
		return nil, err
	}

	if u.Code != int64(code.SettingRpcSuccessful.Code()) {
		return nil, code.BusinessFailure
	}
	resp = &types.Empty{}
	return
}
